export function transformTree(arr, pid) {
  const children = [];
  for (let i = 0; i < arr.length; i++) {
    if (arr[i].pid == pid) {
      const child = arr[i];
      const grandchildren = transformTree(arr, child.id);
      if (grandchildren.length > 0) {
        child.children = grandchildren;
      }
	  child.text = child.name
	  child.value = child.id
      children.push(child);
    }
  }
  return children;
}
function deg2rad(deg) {
  return deg * (Math.PI / 180);
}
export function transformDistance(lat1=0, lon1=0, lat2=0, lon2=0) {
	  const earthRadius = 6371; // 地球半径（单位：公里）
	  // 将角度转换为弧度
	  const dLat = deg2rad(lat2 - lat1);
	  const dLon = deg2rad(lon2 - lon1);
	  // 应用 Haversine 公式计算距离
	  const a =
	    Math.sin(dLat / 2) * Math.sin(dLat / 2) +
	    Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
	    Math.sin(dLon / 2) * Math.sin(dLon / 2);
	  const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
	  const distance = earthRadius * c;
	  return Math.floor(distance);
}
